package com.yin.myproject.design.proxydesign;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 动态代理模式举例--律师代理类
 *
 * @author Eason
 * @create 2018-05-03 23:18
 **/
public class LawerProxyHandler implements InvocationHandler {
    /**
     * 律师替谁打官司
     */
    private Object realObject;

    public LawerProxyHandler(Object realObject) {
        this.realObject = realObject;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("我是律师,我替" + realObject.toString() + "打官司");
        return method.invoke(realObject, args);
    }
}
